package com.mall.shopping.converter;

import com.mall.shopping.dal.entitys.Item;
import com.mall.shopping.dto.CartProductDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @Author Lu piaoyang
 * @Date 2020/9/16 19:11
 * @Version 1.0
 */
@Mapper(componentModel = "spring")
public interface CartConverter {
    @Mappings({
            @Mapping(source = "id",target = "productId"),
            @Mapping(source = "price",target = "salePrice"),
            @Mapping(source = "limitNum",target = "limitNum"),
            @Mapping(source = "title",target = "productName"),
            @Mapping(source = "image",target = "productImg"),
            @Mapping(ignore = true,target = "productNum"),
            @Mapping(ignore = true,target = "checked")
    })
    CartProductDto item2Dto(Item item);

    @Mappings({})
    List<CartProductDto> items2Dto(List<Item> items);
}
